package com.oa.hyperion.repository.assets;

import com.oa.hyperion.entity.assets.AssetsDetail;
import com.oa.hyperion.entity.assets.AssetsRepair;
import com.oa.hyperion.entity.assets.AssetsScrap;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
/**
 * 资产报废
 * author yuanchongwei
 * date 2022-1-18
 */
public interface AssetsScrapMapper {
    /**
     * 资产报废清单，当资产申请报废时写表
     * @param assetsScrap
     */
    @Insert("insert into " +
            "assets_scrap(asset_id,reason,scrap_date,handler) " +
            "values(#{assetId},#{reason},#{scrapDate},#{handler})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    public void insert(AssetsScrap assetsScrap);

    /**
     * 查询所有报废信息
     * @return
     */
    @Select("select * from assets_scrap")
    public List<AssetsScrap> getAssetsScrapInfo();

    /**
     * 查询
     * 根据资产id查询资产报废信息
     * @param asset_id 资产id
     * @return 资产报废信息
     */
    @Select("select * from assets_scrap where asset_id=#{assetId}")
    public AssetsScrap getAssetsScrapByAssetId(int asset_id);

    /**
     * 查询
     * 根据经办人查询资产报废信息
     * @param handler 经办人
     * @return 资产报废信息
     */
    @Select("select * from assets_scrap where handler=#{handler}")
    public List<AssetsScrap> getAssetsScrapByHandler(String handler);
}
